package com.example.demo.dao;

import com.example.demo.entity.jpa.UserInfo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by zhangting on 10/05/2018.
 */
public interface UserJpa extends JpaRepository<UserInfo,Integer> {
        Page<UserInfo> findByAgeEquals(int age, Pageable pageable);
    Page<UserInfo> findByAge(int age, Pageable pageable);
    List<UserInfo> findByUserNameContainsAndAge(String userName,int age);
    List<UserInfo> findByAgeBetweenAndUserNameStartsWithOrderByBornDate(int s,int end ,String u);

    @Query(value = "select a.*, b.country,b.city from user_info a INNER join user_addr b on a.id=b.user_id where a.age=?1" ,nativeQuery = true)
    List<UserInfo> findData(int age);
}
